/*
 * Copyright 1990-2008, Mark Little, University of Newcastle upon Tyne
 * and others contributors as indicated 
 * by the @authors tag. All rights reserved. 
 * See the copyright.txt in the distribution for a
 * full listing of individual contributors. 
 * This copyrighted material is made available to anyone wishing to use,
 * modify, copy, or redistribute it subject to the terms and conditions
 * of the GNU Lesser General Public License, v. 2.1.
 * This program is distributed in the hope that it will be useful, but WITHOUT A 
 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A 
 * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
 * You should have received a copy of the GNU Lesser General Public License,
 * v.2.1 along with this distribution; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, 
 * MA  02110-1301, USA.
 * 
 * (C) 1990-2008,
 */
 /*
 * Calendar Queue for Process List
 *     - See Randy Brown, CACM 30(10): 1220-1227 (10/88).
 *     - See also SIMPACK++ code, Paul Fishwick, cis.ufl.edu.
 *
 * Ian.Mathieson@mel.dit.CSIRO.AU, 11 March 1994.
 */

/*
 * Modified slightly for new C++SIM format (release >= 1.5)
 * by M.C.Little@uk.ac.newcastle.
 * 22/3/94
 */


#if defined(NO_INLINES) && !defined(CALENDAR_CC_)

#else

#ifndef NO_INLINES
#  define INLINEF inline
#else
#  define INLINEF
#endif

INLINEF int Calendar::WhichBucket(double priority) const
{
	// calculate the bucket number for the entry
    int i = int(priority/width);        // find virtual bucket
    i = i % nBuckets;                   // find actual bucket
    return i;
}

INLINEF double Calendar::BucketTop(double priority) const
{
    long n = long(priority/width);
    return (n + 1.5) * width;
}

INLINEF ostream& operator<< (ostream& strm, const Calendar& c)
{
    return c.print(strm);
}

#ifdef INLINEF
#  undef INLINEF
#endif

#endif
